package cn.com.homeyoda.aimate.aihealth.ui.health_qa.record;

import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;
import com.wzq.mvvmsmart.utils.GlideLoadUtils;

import java.util.Arrays;
import java.util.List;
import java.util.Random;

import cn.com.homeyoda.aimate.aihealth.R;
import cn.com.homeyoda.aimate.aihealth.bean.UserRecordsBean;

public class TestRecordAdapter extends BaseQuickAdapter<UserRecordsBean.RowsBean, BaseViewHolder> {

    private static final Random random = new Random();
    private static final List<Integer> imgList = Arrays.asList(R.mipmap.icon_record1, R.mipmap.icon_record2, R.mipmap.icon_record3);

    public TestRecordAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, UserRecordsBean.RowsBean item) {
        helper.setText(R.id.tv_title, item.getQuizName());
        // helper.setText(R.id.tv_answer_count, "答题数：" + item.getCorrectNumber());
        helper.setText(R.id.tv_date, "测试时间：" + item.getAddTimeStr());
        ImageView imageView = helper.getView(R.id.iv_icon);
        GlideLoadUtils.loadRoundCornerImg(imageView,item.getImage(),R.mipmap.ic_kepu1,20);
//        helper.setImageResource(R.id.iv_icon, getRandomImage());
        helper.addOnClickListener(R.id.btn_view_result);
    }
    public static Integer getRandomImage() {
        int index = random.nextInt(imgList.size());
        return imgList.get(index);
    }

    @Override
    public void setNewData(@Nullable List<UserRecordsBean.RowsBean> data) {
        super.setNewData(data);
    }
}
